package com.sc.nft.task;


import com.sc.nft.service.ReportAmountService;
import com.sc.nft.service.ReportBalanceService;
import com.sc.nft.service.ReportTransferService;
import com.sc.nft.service.ReportUserService;
import com.sc.nft.util.WeChatUtil;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * 报表数据统计
 */

@Component
@RequiredArgsConstructor
@Slf4j
public class ReportDataTask {


    private final ReportBalanceService reportBalanceService;
    private final ReportAmountService reportAmountService;
    private final ReportTransferService reportTransferService;
    private final ReportUserService reportUserService;

    /**
     * 报表数据统计
     *
     * @throws Exception
     */
    @XxlJob("reportData")
    public void reportData() throws Exception {

        try {
            reportBalanceService.insertReportBalance();
        }catch (Exception e){
            WeChatUtil.sendWeChatMessage("平台数据概况报表  出错及时查看");
            e.printStackTrace();
        }


        try {
            reportAmountService.insertReportAmount();
        }catch (Exception e){
            WeChatUtil.sendWeChatMessage("财务数据统计报表  出错及时查看");
            e.printStackTrace();
        }

        try {
            reportTransferService.insertReportTransfer();
        }catch (Exception e){
            WeChatUtil.sendWeChatMessage("交易数据统计报表  出错及时查看");
            e.printStackTrace();
        }

        try {
            reportUserService.insertReportUser();
        }catch (Exception e){
            WeChatUtil.sendWeChatMessage("用户数据统计  出错及时查看");
            e.printStackTrace();
        }


    }

    /**
     * 报表数据统计(新版)
     *
     * @throws Exception
     */
    @XxlJob("reportDataEdition")
    public void reportDataEdition() throws Exception {

        try {
            reportBalanceService.insertReportBalanceNewEdition();
        }catch (Exception e){
            WeChatUtil.sendWeChatMessage("平台数据概况报表  出错及时查看");
            e.printStackTrace();
        }


        try {
            reportAmountService.insertReportAmountNewEdition();
        }catch (Exception e){
            WeChatUtil.sendWeChatMessage("财务数据统计报表  出错及时查看");
            e.printStackTrace();
        }

        try {
            reportTransferService.insertReportTransferNewEdition();
        }catch (Exception e){
            WeChatUtil.sendWeChatMessage("交易数据统计报表  出错及时查看");
            e.printStackTrace();
        }

        try {
            reportUserService.insertReportUserNewEdition();
        }catch (Exception e){
            WeChatUtil.sendWeChatMessage("用户数据统计  出错及时查看");
            e.printStackTrace();
        }

//        try {
//            reportUserService.insertEcologyData();
//        }catch (Exception e){
//            WeChatUtil.sendWeChatMessage("生态数据统计  出错及时查看");
//            e.printStackTrace();
//        }


    }
}
